﻿using System;
using System.Linq;

namespace IFramework
{
    public static partial class TypeExtension
    {
        public static object CreatDefault(this Type self)
        {
            return self.IsValueType ? Activator.CreateInstance(self) : null;
        }
        public static bool IsSubClassOfInterface<T>(this Type type)
        {
            return !type.IsInterface && type.GetInterfaces().Contains(typeof(T));
        }
        public static string GetFullName(this Type type, string name)
        {
            string typeName = type.FullName;
            return string.IsNullOrEmpty(name) ? typeName :string.Format("{0}.{1}", typeName, name);
        }
    }
}